<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/include/taglibs.jsp" %>
<html>
<head>
    <%@include file="/include/header.html" %>
    <link rel="stylesheet" href="${ctx}/statics/css/update.css">
    <link rel="stylesheet" href="${ctx}/statics/css/common.css">
    <link rel="stylesheet" href="${ctx}/statics/css/blanceDrop.css">
    <link rel="stylesheet" href="${ctx}/libjs/plugins/laydate/laydate.css">
    <script src="${ctx}/libjs/plugins/laydate/laydate.js"></script>
    <script type="text/javascript" src="${ctx}/appjs/acct/acctDetail.js"></script>
    <script src="${ctx}/libjs/plugins/compressImg/compressImg.js"></script>
    <script src="${ctx}/libjs/plugins/countUp/jquery.countup.min.js"></script>
    <style>
        .layui-layer-btn .layui-layer-btn0 {
            border-color: #E6E3E6 !important;
            background-color: #FFF !important;
            color: black !important;
        }

        .layui-layer-btn .layui-layer-btn1 {
            border-color: #4898d5 !important;
            background-color: #2e8ded !important;
            color: #fff !important;
        }
    </style>
</head>

<script type="text/javascript">
    $('#topLink', window.parent.document).html(function (i, origText) {
        return '<ol class="breadcrumb">' +
            '<li class="breadcrumb-item">' +
            '<a href="">主页</a>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<a>分销商列表</a>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<strong>结算总览</strong>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<a href="javascript:window.history.back()"><i class="fa fa-times"></i> 返回</a>' +
            '</li>' +
            '</ol>';
    });

    var has_add = '';
    var has_edit = '';
    var has_delete = '';

</script>

<body class="gray-bg acctDetailBody">
<div class="wrapper wrapper-content ">
    <div class="col-sm-12">
        <div class="ibox">
            <div class="ibox-body">
                <div class="titleBorder" style="padding: 20px 50px !important;"><span class="titlePiece"></span><span
                        class="orderInfoTitleFont">分销商资金总览</span>
                </div>
                <div class="row topSection">

                    <input type="hidden" id="tenantOperatorCode" name="tenantOperatorCode"
                           value="${tenantOperator.tenantOperatorCode}">

                    <div class="topBlock">
                        <div>钱包</div>
                        <div>
                            <span style="color: white">¥</span>
                            <div id="account" style="display: inline">0</div>
                        </div>
                    </div>
                    <div class="topBlock">
                        <div>待确认账单金额</div>
                        <div>
                            <span style="color: white">¥</span>
                            <div id="unconfirmedAmount" style="display: inline">0</div>
                        </div>
                    </div>
                    <div class="topBlock">
                        <div>提现待审核金额</div>
                        <div>
                            <span style="color: white">¥</span>
                            <div id="withdrawWaitAmount" style="display: inline">0</div>
                        </div>
                    </div>
                    <div class="topBlock">
                        <div>已提现金额</div>
                        <div>
                            <span style="color: white">¥</span>
                            <div id="withdrawAccount" style="display: inline">0</div>
                        </div>
                    </div>
                </div>
                <div class="operateBlock2">
                    <div class="titleBorder" style="padding-top:0 !important;position: absolute;left: 50px"><span
                            class="titlePiece"></span><span class="orderInfoTitleFont">站点收益统计</span>
                    </div>
                    <%--                    <span>${tenantOperator.operatorName}</span>--%>
                    <%--                    <select class="form-control shortInput input-distance" name="stationId" id="stationId">--%>
                    <%--                        <option value="">站点选择</option>--%>
                    <%--                        <c:forEach items="${elecStationResultList}" var="elecStation">--%>
                    <%--                            <option value="${elecStation.elecStationId}">${elecStation.stationName}</option>--%>
                    <%--                        </c:forEach>--%>
                    <%--                    </select>--%>
                    <%--                    <input id="startTime" name="startTime" type="text" readonly--%>
                    <%--                           class="form-control layer-date input-distance timeInput" autocomplete="false"--%>
                    <%--                           placeholder="开始时间">--%>
                    <%--                    <input id="endTime" name="endTime" type="text" readonly--%>
                    <%--                           class="form-control layer-date input-distance timeInput" autocomplete="false"--%>
                    <%--                           placeholder="结束时间">--%>
                    <%--                    <button class="btn btn-success input-distance" onclick="getEchars()">查询</button>--%>
                    <div class="btnDiv">
                        <button class="btn btn-primary input-distance"
                                onclick="acctDetail.tenantOperatorAccountRecord()">
                            余额变动记录
                        </button>
                        <button class="btn btn-warning input-distance"
                                onclick="acctDetail.acctWithdrawApplyByOperator()">提现申请记录
                        </button>
                        <button class="btn btn-primary input-distance" onclick="acctDetail.acctBillOrderOperator()">对账单
                        </button>
                        <button class="btn btn-danger input-distance" onclick="withDrawModal()">发起提现</button>
                    </div>

                </div>
                <%--                <div class="orderDataBox">--%>
                <%--                    &lt;%&ndash;<div class="loadingShade">&ndash;%&gt;--%>
                <%--                    &lt;%&ndash;<img src="${ctx}/statics/img/loading.gif" alt="">&ndash;%&gt;--%>
                <%--                    &lt;%&ndash;</div>&ndash;%&gt;--%>
                <%--                    <div class="orderInfoData">--%>
                <%--                        &lt;%&ndash;<div class="orderInfoIcon orderTotalIcon"></div>&ndash;%&gt;--%>
                <%--                        <div class="orderInfoValue">--%>
                <%--                            <div class="orderDataFontLabel">充电订单</div>--%>
                <%--                            <div class="orderDataFontNumber" id="orderCount"></div>--%>
                <%--                        </div>--%>
                <%--                    </div>--%>
                <%--                    <div class="orderInfoData">--%>
                <%--                        &lt;%&ndash;<div class="orderInfoIcon chargingTimeIcon"></div>&ndash;%&gt;--%>
                <%--                        <div class="orderInfoValue">--%>
                <%--                            <div class="orderDataFontLabel">充电电量</div>--%>
                <%--                            <div class="orderDataFontNumber" id="totalPower"></div>--%>
                <%--                        </div>--%>
                <%--                    </div>--%>
                <%--                    <div class="orderInfoData">--%>
                <%--                        &lt;%&ndash;<div class="orderInfoIcon chargingPowerIcon"></div>&ndash;%&gt;--%>
                <%--                        <div class="orderInfoValue">--%>
                <%--                            <div class="orderDataFontLabel">充电金额</div>--%>
                <%--                            <div class="orderDataFontNumber" id="payAmount"></div>--%>
                <%--                        </div>--%>
                <%--                    </div>--%>
                <%--                    <div class="orderInfoData last">--%>
                <%--                        &lt;%&ndash;<div class="orderInfoIcon totalAmountIcon"></div>&ndash;%&gt;--%>
                <%--                        <div class="orderInfoValue">--%>
                <%--                            <div class="orderDataFontLabel">所获收益</div>--%>
                <%--                            <div class="orderDataFontNumber" id="factAmount"></div>--%>
                <%--                        </div>--%>
                <%--                    </div>--%>
                <%--                </div>--%>
                <%--                <div id="main" style="width: 95%;height:300px;margin: 20px auto 30px"></div>--%>
                <table id="exampleTable" data-mobile-responsive="true">
                </table>
            </div>
            <div class="withDrawModal" id="withDrawModal" style="display: none;">
                <h1>请选择对应账单上传相关发票申请提现</h1>
                <div class="contentBlock">
                    <div class="leftBlock" id="totalMoney">提现金额:</div>
                    <div class="rightBlock">
                        <div>
                            <input type="input" class="amount"
                                   onkeyup="var p2 = parseFloat(value).toFixed(2);value = p2>=0?(/\.0?$/.test(value)?value:p2.replace(/0$/,'').replace(/\.0$/,'')):''"
                                   onblur="value = value.replace(/\.0*$/,'')"
                                   id="withdrawAmount" readonly placeholder="请勾选对应账单">
                            <span>元</span>
                            <span style="padding-left: 50px">(其中电费<span
                                    id="elecAmount">0</span>&nbsp;&nbsp;&nbsp;服务费<span id="serviceAmount">0</span>&nbsp;&nbsp;&nbsp;提现手续费<span
                                    id="withdrawServiceCharge">0</span>)</span>
                        </div>
                        <div class="choiceBlock">
                            <ul>
                                <li class="checkallList"><input lay-skin="primary" type="checkbox" id="checkall"
                                                                name="type" lay-filter="allChoose"
                                                                value="checkall"/><span>全选</span></li>
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="contentBlock">
                    <div class="leftBlock">提现到:</div>
                    <div class="rightBlock">
                        <select name="" id="acctBankList" style="width: 50% !important;">
                            <c:forEach items="${acctBankList}" var="item">
                                <c:if test="${item.withdrawType eq 0}">
                                    <option value="${item.withdrawType},${item.alipayUserName},${item.alipayUserId}">支付宝&nbsp;&nbsp;${item.alipayUserId}</option>
                                </c:if>
                                <c:if test="${item.withdrawType eq 1}">
                                    <option value="${item.withdrawType},${item.acctBankCode},${item.acctBank},${item.acctBankAccount}">${item.acctBankName}&nbsp;&nbsp;${item.acctBankAccount}</option>
                                </c:if>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="contentBlock" style="align-items: flex-start;">
                    <div class="leftBlock">上传发票:</div>
                    <div class="rightBlock" style="padding-right: 30px;">
                        <div id="frmElecStation" style="position:relative">
                            <div class="imgBlock">
                                <img id="stationImg" src="${ctx}/statics/img/newEdition/pdf.png"
                                     style="position: relative" width="40px" height="40px">
                                <input type="file" id="file1" name="file1" style="width: 80px;height:80px !important"/>
                                <span class="priviewBtn hide">预览</span>
                                <span class="delIcon hide"></span>
                            </div>
                            <div class="imgBlock">
                                <img id="stationImg2" src="${ctx}/statics/img/newEdition/pdf.png"
                                     style="position: relative" width="40px" height="40px">
                                <input type="file" id="file2" name="file1" style="width: 80px;height:80px !important"/>
                                <span class="priviewBtn hide">预览</span>
                                <span class="delIcon hide"></span>
                            </div>
                            <div class="imgBlock">
                                <img id="stationImg3" src="${ctx}/statics/img/newEdition/pdf.png"
                                     style="position: relative" width="40px" height="40px">
                                <input type="file" id="file3" name="file1" style="width: 80px;height:80px !important"/>
                                <span class="priviewBtn hide">预览</span>
                                <span class="delIcon hide"></span>
                            </div>
                            <div class="imgBlock">
                                <img id="stationImg4" src="${ctx}/statics/img/newEdition/pdf.png"
                                     style="position: relative" width="40px" height="40px">
                                <input type="file" id="file4" name="file1" style="width: 80px;height:80px !important"/>
                                <span class="priviewBtn hide">预览</span>
                                <span class="delIcon hide"></span>
                            </div>
                            <div class="imgBlock">
                                <img id="stationImg5" src="${ctx}/statics/img/newEdition/pdf.png"
                                     style="position: relative" width="40px" height="40px">
                                <input type="file" id="file5" name="file1" style="width: 80px;height:80px !important"/>
                                <span class="priviewBtn hide">预览</span>
                                <span class="delIcon hide"></span>
                            </div>
                            <div class="imgBlock">
                                <img id="stationImg6" src="${ctx}/statics/img/newEdition/pdf.png"
                                     style="position: relative" width="40px" height="40px">
                                <input type="file" id="file6" name="file1" style="width: 80px;height:80px !important"/>
                                <span class="priviewBtn hide">预览</span>
                                <span class="delIcon hide"></span>
                            </div>
                            <div class="imgBlock">
                                <img id="stationImg7" src="${ctx}/statics/img/newEdition/pdf.png"
                                     style="position: relative" width="40px" height="40px">
                                <input type="file" id="file7" name="file1" style="width: 80px;height:80px !important"/>
                                <span class="priviewBtn hide">预览</span>
                                <span class="delIcon hide"></span>
                            </div>
                            <div class="imgBlock">
                                <img id="stationImg8" src="${ctx}/statics/img/newEdition/pdf.png"
                                     style="position: relative" width="40px" height="40px">
                                <input type="file" id="file8" name="file1" style="width: 80px;height:80px !important"/>
                                <span class="priviewBtn hide">预览</span>
                                <span class="delIcon hide"></span>
                            </div>
                            <div class="imgBlock">
                                <img id="stationImg9" src="${ctx}/statics/img/newEdition/pdf.png"
                                     style="position: relative" width="40px" height="40px">
                                <input type="file" id="file9" name="file1" style="width: 80px;height:80px !important"/>
                                <span class="priviewBtn hide">预览</span>
                                <span class="delIcon hide"></span>
                            </div>
                            <div class="imgBlock">
                                <img id="stationImg10" src="${ctx}/statics/img/newEdition/pdf.png"
                                     style="position: relative" width="40px" height="40px">
                                <input type="file" id="file10" name="file1" style="width: 80px;height:80px !important"/>
                                <span class="priviewBtn hide">预览</span>
                                <span class="delIcon hide"></span>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="contentBlock" style="justify-content:center">tips:请上传对应提现金额的发票，平台会对发票以及提现金额进行审核，审核通过，正式转账！
                </div>
                <div class="contentBlock" style="align-items:center;margin-top:30px">
                    <div class="leftBlock">备注:</div>
                    <div class="rightBlock"><textarea rows="5" cols="50" id="remark"></textarea></div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    // acctDetail.init();
    $(function () {
        $('#hlhtOrderType').searchableSelect();
    })
    // //日期范围限制
    var start = {
        elem: '#startTime',
        format: 'YYYY-MM-DD hh:mm:ss',
        // theme: '#3195f0',
        // min: laydate.now(), //设定最小日期为当前日期
        // max: '2099-06-16 23:59:59', //最大日期
        istime: true,
        istoday: false,
        choose: function (datas) {
            $("#endTime").val("")
            end.min = datas
        }
    };
    var end = {
        elem: '#endTime',
        format: 'YYYY-MM-DD hh:mm:ss',
        // theme: '#3195f0',
        // min: laydate.now(),
        // max: '2099-06-16 23:59:59',
        istime: true,
        istoday: false,
        choose: function (datas) {
            start.max = datas; //结束日选好后，重置开始日的最大日期
        }
    };
    laydate(start);
    laydate(end);
    laydate.skin('molv');//皮肤
</script>
</body>
<script>
    var options = {
        useEasing: true,
        useGrouping: true,
        separator: ',',
        decimal: '.'
    };
</script>
</html>
<script>
    var totalPayamount = 0;
    //全选反选
    $(".acctDetailBody").on("click", "#checkall", function () {
        if ($(this).prop("checked")) {
            $("input[type='checkbox']").prop("checked", true);
            countPayAmount()
        } else {
            $("input[type='checkbox']").prop("checked", false);
            countPayAmount()
        }
    })
    $(".acctDetailBody").on("click", ".checkallList span", function (e) {
        if ($(this).siblings("input[type='checkbox']").prop("checked")) {
            $(this).siblings("input[type='checkbox']").prop("checked", false);
            $("input[type='checkbox']").prop("checked", false);
            countPayAmount()
        } else {
            $(this).siblings("input[type='checkbox']").prop("checked", true);
            $("input[type='checkbox']").prop("checked", true);
            countPayAmount()
        }
    })

    function countPayAmount() {
        totalPayamount = 0;
        totalElecamount = 0;
        totalServiceamount = 0;
        if ($(".checkboxList input:checked").length > 0) {
            $(".checkboxList input:checked").each(function () {
                totalPayamount += parseFloat($(this).parents(".checkboxList").attr("payAmount"));
                totalElecamount += parseFloat($(this).next().text());
                totalServiceamount += parseFloat($(this).next().next().text());
                // $("#withdrawAmount").val(totalPayamount.toFixed(2));
                $("#elecAmount").text(totalElecamount.toFixed(2));
                $("#serviceAmount").text(totalServiceamount.toFixed(2));
            })
            totalPayamount -= parseFloat($("#withdrawServiceCharge").text()).toFixed(2);
            $("#withdrawAmount").val(totalPayamount.toFixed(2))
        } else {
            $("#withdrawAmount").val("");
            $("#elecAmount").text("0");
            $("#serviceAmount").text("0");
        }
    }

    //多选
    $(".acctDetailBody").on("click", ".checkboxList span", function (e) {
        if ($(this).siblings("input[type='checkbox']").prop("checked")) {
            $(this).siblings("input[type='checkbox']").prop("checked", false);
            countPayAmount()
        } else {
            $(this).siblings("input[type='checkbox']").prop("checked", true);
            countPayAmount()
        }
        var listLength = $(".checkboxList").find("input[type='checkbox']").length;
        if ($(".checkboxList input[type='checkbox']:checked").length == listLength) {
            $("#checkall").prop("checked", true);
        } else {
            $("#checkall").prop("checked", false);
        }

    })
    $(".acctDetailBody").on("click", ".checkboxList input", function (e) {
        var listLength = $(".checkboxList").find("input[type='checkbox']").length;
        if ($(".checkboxList input[type='checkbox']:checked").length == listLength) {
            $("#checkall").prop("checked", true);
            countPayAmount()
        } else {
            $("#checkall").prop("checked", false);
            countPayAmount()
        }
    })

    $(".acctDetailBody").on("change", "input[type='file']", function (event) {
        var objUrl = getObjectURL(this.files[0]);//获取文件信息
        var fileSize = $(this)[0].files[0].size
        if (objUrl) {
            if (fileSize > (2 * 1024 * 1024)) {
                layer.msg('请上传小于2M的图片！');
                $(this).val("");
                return
            }
        }
        var that = $(this);
        var fileData = this.files[0];
        var formData = new FormData();
        formData.append('file', fileData);
        $.ajax({
            "url": jsctx + "/acctTenantOperator/saveInvoicePDF",
            "method": "POST",
            "data": formData,
            "processData": false,
            "contentType": false,
            "beforeSend": function () {
                layer.msg("上传中...", {time: -1});
            },
            "success": function (data) {
                console.log(data)
                if (data.status == 200) {
                    layer.msg("上传成功！", {time: 1000});
                    that.siblings("img").attr("src", '${ctx}/statics/img/newEdition/pdf_1.png');
                    that.siblings(".priviewBtn").removeClass("hide").attr("url", (data.data).split(',')[0] + (data.data).split(',')[1]).attr("backUrl", (data.data).split(',')[1]).addClass("success");
                    that.siblings(".delIcon").removeClass("hide");
                } else {
                    layer.msg(data.message);
                }
            }
        })

    });

    $(".acctDetailBody").on("click", ".priviewBtn", function (e) {
        e.stopPropagation();
        var objUrl = $(this).attr("url");
        window.open(objUrl)
    })
    $(".acctDetailBody").on("click", ".delIcon", function (e) {
        e.stopPropagation();
        $(this).siblings("input[tupe='file']").val("");
        $(this).siblings(".priviewBtn").addClass("hide").removeClass("success").removeAttr("url");
        $(this).addClass("hide");
        $(this).siblings("img").attr("src", "${ctx}/statics/img/newEdition/pdf.png");
    })

    $(".acctDetailBody").on("click", ".checkboxList input", function (e) {
        var listLength = $(".checkboxList").find("input[type='checkbox']").length;
        if ($(".checkboxList input[type='checkbox']:checked").length == listLength) {
            $("#checkall").prop("checked", true);
        } else {
            $("#checkall").prop("checked", false);
        }
    })
</script>
<script>
    var h = $(window).height() - 80;
    $('#exampleTable')
        .bootstrapTable(
            {
                method: 'get',
                url: prefix + "/listPageAcctBillOrder",
                iconSize: 'outline',
                toolbar: '#exampleToolbar',
                striped: false,
                dataType: "json",
                pagination: true,
                singleSelect: false,
                pageSize: 20,
                pageList: [10, 20, 30],
                pageNumber: 1,
                sidePagination: "server",
                paginationShowPageGo: true,
                height: h,
                rightFixedColumns: true,
                showColumns: false,
                queryParams: function (params) {
                    return {
                        limit: params.limit,
                        offset: (params.offset / params.limit) + 1,
                        tenantOperatorCode: $('#tenantOperatorCode').val(),
                        billOrderNum: $('#billOrderNum').val(),
                        elecStationId: $('#elecStationId').val(),
                        status: $('#status').val(),
                        startTime: $('#startTime').val(),
                        endTime: $('#endTime').val(),
                        //运营商为0,分销商为1,分销商结算总览2
                        userType: 2,
                    };
                },
                columns: [
                    {
                        title: '#', field: '', width: '50', align: 'left',
                        formatter: function (value, row, index) {
                            return index + 1;
                        }
                    },
                    {field: 'createdTime', title: '时间', width: '120', align: 'left',},
                    {field: 'elecAcctAmount', title: '结算电费', width: '120', align: 'left',},
                    {field: 'serviceAcctAmount', title: '结算服务费', width: '120', align: 'left',},
                    {field: 'totalAcctAmount', title: '总收入', width: '120', align: 'left',}
                ]
            });

    function getObjectURL(file) {
        var url = null;
        if (window.createObjectURL != undefined) {
            url = window.createObjectURL(file);
        } else if (window.URL != undefined) { // mozilla(firefox)
            url = window.URL.createObjectURL(file);
        } else if (window.webkitURL != undefined) { // webkit or chrome
            url = window.webkitURL.createObjectURL(file);
        }
        return url;
    }

    var tenantOperatorCode = $("#tenantOperatorCode").val()

    function getTenantOperatorAccountData() {
        $.ajax({
            "url": jsctx + "/acctTenantOperator/tenantOperatorAccountData?random=" + Math.random(),
            "method": "GET",
            "data": {
                tenantOperatorCode: tenantOperatorCode,
            },
            "success": function (data) {
                new CountUp("unconfirmedAmount", 0, data.data.unconfirmedAmount, 2, 3, options).start();
                new CountUp("account", 0, data.data.account, 2, 3, options).start();
                new CountUp("withdrawAccount", 0, data.data.withdrawAccount, 2, 3, options).start();
                new CountUp("withdrawWaitAmount", 0, data.data.withdrawWaitAmount, 2, 3, options).start();
                // $("#unconfirmedAmount").text('¥' + data.data.unconfirmedAmount)
                // $("#withdrawWaitAmount").text('¥' + data.data.withdrawWaitAmount)
                // $("#account").text('¥' + data.data.account)
                // $("#withdrawAccount").text('¥' + data.data.withdrawAccount)
                console.log(data)
            }
        })
    }

    function getTenantOperatorOrderData() {
        $.ajax({
            "url": jsctx + "/acctTenantOperator/tenantOperatorOrderData?random=" + Math.random(),
            "method": "GET",
            "data": {
                tenantOperatorCode: tenantOperatorCode,
                stationId: $("#stationId").val(),
                startTime: $("#startTime").val(),
                endTime: $("#endTime").val(),
            },
            "success": function (data) {
                $("#orderCount").text(data.data.orderCount + '单')
                $("#totalPower").text(data.data.totalPower + '度')
                $("#payAmount").text('¥' + data.data.payAmount)
                $("#factAmount").text('¥' + data.data.factAmount)
                console.log(data)
            }
        })
    }

    var tem;

    function getTenantOperatorAcctSetting() {
        $.ajax({
            "url": jsctx + "/acctTenantOperator/selectTenantOperatorAcctSetting",
            "method": "GET",
            "data": {
                "tenantOperatorCode": tenantOperatorCode
            },
            "success": function (data) {
                if (data.status == 200) {
                    // console.log(data);
                    tem = data.data.uploadInvoice;
                    $("#withdrawServiceCharge").text(data.data.withdrawServiceCharge);
                } else {
                    return false;
                }
            }
        });
    }


    getTenantOperatorOrderData()
    getTenantOperatorAccountData()
    getTenantOperatorAcctSetting()

    // getEchars()

    function withDrawModal(id, name) {
        // alert("发起提现");
        layer.open({
            type: 1,
            title: '提现',
            closeBtn: false,
            shade: 0.4,
            shift: 7,
            maxWidth: '622px',
            shadeClose: true,
            content: $("#withDrawModal"),
            btn: ['取消', '提交提现申请'],
            btn1: function (index) {//layer.msg('yes');    //取消
                layer.close(index);
            },
            btn2: function (index) {//取消
                // var totalAmount=$("#totalMoney").val();
                // if(totalAmount<0){
                //     alert("提现金额不能为负数");
                //     return false;
                // }
                var acctBankList = $("#acctBankList").val().split(",");
                var withdrawType, withdrawAmount, withdrawElecAmount, withdrawServiceAmount, alipayUserName,
                    alipayUserId, remark, acctBankCode, acctBank,
                    acctBankAccount;
                if (acctBankList[0] == "0") {
                    withdrawType = 0
                    withdrawAmount = $("#withdrawAmount").val();
                    withdrawElecAmount = $("#elecAmount").text();
                    withdrawServiceAmount = $("#serviceAmount").text();
                    alipayUserName = acctBankList[1];
                    alipayUserId = acctBankList[2];
                    remark = $("#remark").val();
                } else if (acctBankList[0] == "1") {
                    withdrawType = 1
                    withdrawAmount = $("#withdrawAmount").val();
                    withdrawElecAmount = $("#elecAmount").text();
                    withdrawServiceAmount = $("#serviceAmount").text();
                    acctBankCode = acctBankList[1];
                    acctBank = acctBankList[2];
                    acctBankAccount = acctBankList[3];
                    remark = $("#remark").val();
                }
                var acctBillOrderList = '';
                var invoiceList = '';
                var OrderListArr = [];
                var invoiceListArr = [];
                // let tenantOperatorCode = $("#tenantOperatorCode").val();
                if ($("#withdrawAmount").val() == "") {
                    alert("请勾选对应账单");
                    return false;
                } else if ($("#withdrawAmount").val() <= 0) {
                    alert("提现金额需大于0元");
                    return false;
                }
                if ($(".checkboxList input:checked").length > 0) {
                    $(".checkboxList input:checked").each(function () {
                        OrderListArr.push($(this).val());
                    })
                    acctBillOrderList = OrderListArr.join(",")
                }

                if ($(".success").length > 0) {
                    $(".success").each(function () {
                        invoiceListArr.push($(this).attr("backUrl"))
                    })
                    invoiceList = invoiceListArr.join(",");
                } else {
                    if (tem == 0) {
                        alert("请上传发票");
                        return false;
                    }
                }
                $.ajax({
                    "url": jsctx + "/acctTenantOperator/saveAcctWithdrawApply",
                    "method": "POST",
                    "data": {
                        tenantOperatorCode: $("#tenantOperatorCode").val(),
                        withdrawType: withdrawType,
                        withdrawAmount: withdrawAmount,
                        withdrawElecAmount: withdrawElecAmount,
                        withdrawServiceAmount: withdrawServiceAmount,
                        alipayUserName: alipayUserName,
                        alipayUserId: alipayUserId,
                        acctBankCode: acctBankCode,
                        acctBank: acctBank,
                        acctBankAccount: acctBankAccount,
                        remark: remark,
                        acctBillOrderList: JSON.stringify(acctBillOrderList.split(",")),
                        invoiceList: JSON.stringify(invoiceList.split(","))
                    },
                    "success": function (data) {
                        if (data.status == 200) {
                            layer.msg("提现申请记录已提交");
                            listAcctBillOrderForComplete();
                            getTenantOperatorAccountData();
                            $("input[tupe='file']").val("");
                            $(".priviewBtn").addClass("hide").removeClass("success").removeAttr("url");
                            $(".delIcon").addClass("hide");
                            $(".imgBlock").find("img").attr("src", "${ctx}/statics/img/newEdition/pdf.png");
                            $(".amount").val("");
                            $("#remark").val("");
                            $("#elecAmount").text("0");
                            $("#serviceAmount").text("0");
                        } else {
                            layer.msg("提交提现申请失败");
                            return false;
                        }
                    }
                })

            },
            end: function (index) {
                layer.close(index);
                $("input[type='file']").val("");
                $("input[type='checkbox']").prop("checked", false);
                $(".priviewBtn").addClass("hide").removeClass("success").removeAttr("url");
                $(".delIcon").addClass("hide");
                $(".imgBlock").find("img").attr("src", "${ctx}/statics/img/newEdition/pdf.png");
                $(".amount").val("");
                $("#elecAmount").text("0");
                $("#serviceAmount").text("0");
                $("#remark").val("");
            }
        });

    }

    function listAcctBillOrderForComplete() {
        $.ajax({
            "url": jsctx + "/acctTenantOperator/listAcctBillOrderForComplete?random=" + Math.random(),
            "method": "GET",
            "data": {
                tenantOperatorCode: $("#tenantOperatorCode").val(),
            },
            "success": function (data) {
                if (data.status == 200) {
                    $(".choiceBlock ul").html("");
                    var str1 = "<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style='width:30px;'>电费</span><span style='width:60px;padding-left:20px'>服务费</span><span style='width: 270px;padding-left: 20px'>账单时间</span><span style='width: 30px'>站点</span></li>";
                    var str = ''
                    for (var i = 0; i < data.data.length; i++) {
                        if (data.data[i].elecAcctAmount + data.data[i].serviceAcctAmount < 0) {
                            str += "<li class='checkboxList' payAmount='" + data.data[i].factAmount + "'>" + "<input lay-skin='primary' type='checkbox' checked='checked'  name='' value='" + data.data[i].billOrderId + "'/>" + "<span style='font-weight:700;width:max-content'>" + data.data[i].elecAcctAmount + "</span>" + '&nbsp;&nbsp;&nbsp;&nbsp;' + "<span style='font-weight:700;width:max-content'>" + data.data[i].serviceAcctAmount + "</span>" + '&nbsp;&nbsp;' + '&nbsp;&nbsp;' + "<span>" + data.data[i].billStartTime + '&nbsp;&nbsp;' + data.data[i].billEndTime + '&nbsp;&nbsp;' + data.data[i].stationName + "</span>" + "</li>"
                        } else {
                            str += "<li class='checkboxList' payAmount='" + data.data[i].factAmount + "'>" + "<input lay-skin='primary' type='checkbox'  name='' value='" + data.data[i].billOrderId + "'/>" + "<span style='font-weight:700;width:max-content'>" + data.data[i].elecAcctAmount + "</span>" + '&nbsp;&nbsp;&nbsp;&nbsp;' + "<span style='font-weight:700;width:max-content'>" + data.data[i].serviceAcctAmount + "</span>" + '&nbsp;&nbsp;' + '&nbsp;&nbsp;' + "<span>" + data.data[i].billStartTime + '&nbsp;&nbsp;' + data.data[i].billEndTime + '&nbsp;&nbsp;' + data.data[i].stationName + "</span>" + "</li>"
                        }
                    }
                    $(".choiceBlock ul").append(str1 + str)
                }
            }
        })
    }

    listAcctBillOrderForComplete()

    //获取数据
    function getEchars() {
        getTenantOperatorOrderData()
        var myChart = echarts.init(document.getElementById('main'));
        myChart.showLoading();
        $.ajax({
            "url": jsctx + "/acctTenantOperator/tenantOperatorOrderECharData?random=" + Math.random(),
            "method": "GET",
            "data": {
                tenantOperatorCode: tenantOperatorCode,
                stationId: $("#stationId").val(),
                startTime: $("#startTime").val(),
                endTime: $("#endTime").val(),
            },
            "success": function (data) {
                // if(data.data.length>0){
                d(data, myChart);
                myChart.hideLoading();
            }
        })

    }

    function d(data, myChart) {
        console.log(data)
        var dateXAxis = new Array()
        var amountYAxis = new Array()

        for (var i = 0; i < data.data.length; i++) {
            dateXAxis.push(data.data[i].year + '.' + data.data[i].month);
            amountYAxis.push(parseFloat(data.data[i].factAmount));
        }
        if (dateXAxis.length == 0) {
            dateXAxis.push('');
        }
        if (amountYAxis.length == 0) {
            amountYAxis.push(0);
        }
        console.log(amountYAxis)
        // 基于准备好的dom，初始化echarts实例
        option = {
            color: ['#3398db'],
            tooltip: {
                trigger: 'axis',
                axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                    type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                }
            },
            grid: {
                left: '0%',
                right: '0%',
                bottom: '0%',
                containLabel: true
            },
            xAxis: [
                {
                    type: 'category',
                    data: dateXAxis,
                    axisTick: {
                        alignWithLabel: true
                    }
                }
            ],
            yAxis: [
                {
                    name: '金额',
                    type: 'value'
                }
            ],
            series: [
                {
                    type: 'bar',
                    barWidth: '10%',
                    data: amountYAxis
                }
            ]
        };
        myChart.setOption(option);

    };
</script>
